//banner轮播
var swiper_banner = new Swiper('.banner', {
	pagination: {
		el: '.swiper-pagination',
		clickable: true,
	},
	navigation: {
		nextEl: '.next_btn',
		prevEl: '.prev_btn',
	},
	autoplay: {
		pauseOnMouseEnter: true,
	},
});
swiper_banner.el.onmouseover = function() {
	swiper_banner.autoplay.stop();
}
swiper_banner.el.onmouseout = function() {
	swiper_banner.autoplay.start();
};

//明星产品左右切换
var swiper_product = new Swiper('.str_product_item', {
	slidesPerView: 1,
	spaceBetween: 30,
	keyboard: {
		enabled: true,
	},
	navigation: {
		nextEl: '.str_product_next',
		prevEl: '.str_product_prev',
	},
});

//跳楼层
var leftFixedLi = document.querySelectorAll(".left_fixed li");
var floor = document.querySelectorAll(".floor");
Array.from(leftFixedLi).forEach(function(item, index) {
	item.onclick = function() {
		var offsetTop = floor[index].offsetTop;
		jumpfloor(offsetTop);
	}
});

function jumpfloor(offsetTop) {
	var scrollTop = document.documentElement.scrollTop;
	clearInterval(time);
	var time = setInterval(function() {
		scrollTop = scrollTop - (scrollTop - offsetTop) / 5;
		if (Math.abs(scrollTop - offsetTop) < 1) {
			scrollTop = offsetTop;
			clearInterval(time);
		}
		document.documentElement.scrollTop = scrollTop;
	}, 30)
	document.documentElement.scrollTop = scrollTop;
}
var nav_content = document.querySelector(".nav_content");
		var nav = document.querySelector(".nav");
		document.onscroll = function() {
			var left_fixed = document.querySelector(".left_fixed");
			var scroll_top = document.documentElement.scrollTop;
			var nav_top = nav_content.offsetTop;
			if (scroll_top > 700) {
				left_fixed.style.opacity = 1;
				left_fixed.style.pointerEvents = "all";
			} else {
				left_fixed.style.opacity = 0;
				left_fixed.style.pointerEvents = "none";
			};
			if (nav_top < scroll_top) {
					nav_content.classList.add("nav_fixed");
				};
				if (scroll_top < nav.offsetTop) {
					nav_content.classList.remove("nav_fixed");
				};
			
			if (scroll_top > 800) {
				backtop.style.display = "block";
			} else {
				backtop.style.display = "none";
			}
		}
$(".cartNum").text(countPrice().goodsNum)